import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

// 扫码乘车
const Home = resolve => require(['@/views/Home'], resolve)

// 失物招领
const LostFind = resolve => require(['@/views/lost-find/LostFind'], resolve)
const LostRegister = resolve => require(['@/views/lost-find/LostRegister'], resolve)
const LostRegisterResult = resolve => require(['@/views/lost-find/LostRegisterResult'], resolve)

// 新闻公告
const Notice = resolve => require(['@/views/Notice'], resolve)
const NoticeDetail = resolve => require(['@/views/NoticeDetail'], resolve)

// 充值记录与明细
const RechargeRecords = resolve => require(['@/views/recharge-records/RechargeRecords'], resolve)
const RechargeDetails = resolve => require(['@/views/recharge-records/RechargeDetails'], resolve)
const PaymentDetails = resolve => require(['@/views/recharge-records/PaymentDetails'], resolve)
const Recharge = resolve => require(['@/views/recharge-records/Recharge'], resolve)
const PayResult = resolve => require(['@/views/recharge-records/PayResult'], resolve)

const PaySuccess = resolve => require(['@/views/pay/PaySuccess'], resolve)
/**
 *
 * @type title 看页面需求，需要则填 不需要为空即可
 */
let routes = [
  {
    path: '/',
    redirect: '/view/home', // 重定向
    component: Home
  },
  {
    path: '/view/home',
    name: 'home',
    component: Home,
    meta: {
      title: ''
    }
  },
  {
    path: '/view/notice',
    name: 'notice',
    component: Notice,
    meta: {
      title: ''
    }
  },
  {
    path: '/view/noticeDetail',
    name: 'noticeDetail',
    component: NoticeDetail,
    meta: {
      title: ''
    }
  },
  {
    path: '/view/rechargeRecords/rechargeRecords',
    name: 'rechargeRecords',
    component: RechargeRecords,
    meta: {
      title: '公交卡账单明细'
    }
  },
  {
    path: '/view/rechargeRecords/rechargeDetails',
    name: 'rechargeDetails',
    component: RechargeDetails,
    meta: {
      title: '充值明细'
    }
  },
  {
    path: '/view/rechargeRecords/paymentDetails',
    name: 'paymentDetails',
    component: PaymentDetails,
    meta: {
      title: '支付明细'
    }
  },
  {
    path: '/view/rechargeRecords/recharge',
    name: 'recharge',
    component: Recharge,
    meta: {
      title: '公交卡充值'
    }
  },
  {
    path: '/view/rechargeRecords/payResult',
    name: 'payResult',
    component: PayResult,
    meta: {
      title: ''
    }
  },
  {
    path: '/view/lostFind',
    name: 'lostFind',
    component: LostFind,
    meta: {
      title: '失物招领'
    }
  },
  {
    path: '/view/lostRegister',
    name: 'lostRegister',
    component: LostRegister,
    meta: {
      title: ''
    }
  },
  {
    path: '/view/lostRegisterResult',
    name: 'lostRegisterResult',
    component: LostRegisterResult,
    meta: {
      title: ''
    }
  },
  {
    path: '/view/paySuccess',
    name: 'paySuccess',
    component: PaySuccess,
    meta: {
      title: ''
    }
  }
]

export default new Router({
  mode: 'history',
  base: 'sweepYardsRide',
  routes: routes,
  scrollBehavior (to, from, savedPosition) {
    return {x: 0, y: 0}
  }
})
